package com.wswy.wzcx.utils

import android.content.Context
import android.util.SparseIntArray
import android.util.TypedValue


object ResUtils {

    private val sAttrs = SparseIntArray()

    private fun getAttrResourceId(context: Context, attrId: Int): Int {
        var id = sAttrs.get(attrId, -1)
        if (id > 0) {
            return id
        }
        try {
            val outValue = TypedValue()
            context.theme.resolveAttribute(attrId, outValue, true)
            id = outValue.resourceId
            sAttrs.put(attrId, id)
        } catch (e: Exception) {
            e.printStackTrace()
            id = 0
        }

        return id
    }


    fun getSelectableItemBackgroundBorderless(context: Context): Int {
        return getAttrResourceId(context, android.support.v7.appcompat.R.attr.selectableItemBackgroundBorderless)
    }

    fun getSelectableItemBackground(context: Context): Int {
        return getAttrResourceId(context, android.support.v7.appcompat.R.attr.selectableItemBackground)
    }


}
